package gov.nist.applet.phone.ua.gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class AddNewAccountDialog extends JDialog {

	private static final long serialVersionUID = 1L;

	private JPanel contentPane = null;
	private JLabel jlTitle = null;
	private JLabel jlUsername = null;
	private JTextField jtfUsername = null;
	private JLabel jlPassword = null;
	private JTextField jtfPassword = null;
	private JLabel jlPort = null;
	private JTextField jtfPort = null;
	private JCheckBox jcbKeep = null;

	private JButton jbAdvance = null;
	private JButton jbOK = null;
	private JButton jbCancel = null;

	public AddNewAccountDialog(Frame owner) {
		super(owner);
		initialize();
	}

	private void initialize() {
		this.setSize(400, 300);
		this.setTitle("添加新帐号");
		this.setLayout(null);
		this.setContentPane(getContentPanel());
		this.setResizable(false);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setLocationRelativeTo(null);// 显示在屏幕中央
		setVisible(true);
	}

	private JPanel getContentPanel() {
		contentPane = new JPanel() {
			private static final long serialVersionUID = 1L;

			protected void paintComponent(Graphics g) {
				super.paintComponent(g);
				ImageIcon img = new ImageIcon(
						AddNewAccountDialog.class
								.getResource("/images/addAccount/newAccount.png"));
				g.drawImage(img.getImage(), 0, 0, null);
			};
		};
		contentPane.setBackground(Color.WHITE);
		contentPane.setLayout(null);

		jlTitle = new JLabel("新建账户", new ImageIcon(
				AddNewAccountDialog.class
						.getResource("/images/addAccount/account.png")), 0);
		jlTitle.setSize(200, 40);
		jlTitle.setLocation(100, 5);
		jlTitle.setFont(new Font("宋体", Font.PLAIN, 18));
		contentPane.add(jlTitle);

		jlUsername = new JLabel("用户名");
		jlUsername.setSize(80, 30);
		jlUsername.setLocation(70, 50);
		jlUsername.setFont(new Font("宋体", Font.PLAIN, 15));

		jtfUsername = new JTextField();
		jtfUsername.setSize(160, 30);
		jtfUsername.setLocation(130, 50);
		jtfUsername.setOpaque(false);
		contentPane.add(jlUsername);
		contentPane.add(jtfUsername);

		jlPassword = new JLabel("密  码");
		jlPassword.setSize(80, 30);
		jlPassword.setLocation(70, 90);
		jlPassword.setFont(new Font("宋体", Font.PLAIN, 15));

		jtfPassword = new JTextField();
		jtfPassword.setSize(160, 30);
		jtfPassword.setLocation(130, 90);
		jtfPassword.setOpaque(false);
		contentPane.add(jlPassword);
		contentPane.add(jtfPassword);

		jlPort = new JLabel("端  口");
		jlPort.setSize(80, 30);
		jlPort.setLocation(70, 130);
		jlPort.setFont(new Font("宋体", Font.PLAIN, 15));

		jtfPort = new JTextField();
		jtfPort.setSize(60, 30);
		jtfPort.setLocation(130, 130);
		jtfPort.setOpaque(false);
		contentPane.add(jlPort);
		contentPane.add(jtfPort);

		jcbKeep = new JCheckBox("保存密码");
		jcbKeep.setSelected(true);
		jcbKeep.setSize(100, 30);
		jcbKeep.setLocation(130, 170);
		jcbKeep.setOpaque(false);
		contentPane.add(jcbKeep);

		jbAdvance = new JButton("高级");
		jbAdvance.setSize(60, 30);
		jbAdvance.setLocation(40, 210);
		jbAdvance.setFont(new Font("宋体", Font.PLAIN, 12));
		jbAdvance.setHorizontalTextPosition(JButton.CENTER);
		jbAdvance.setOpaque(false);

		contentPane.add(jbAdvance);

		jbOK = new JButton("添加");
		jbOK.setSize(60, 30);
		jbOK.setLocation(230, 210);
		jbOK.setFont(new Font("宋体", Font.PLAIN, 12));
		jbOK.setHorizontalTextPosition(JButton.CENTER);
		jbOK.setOpaque(false);

		contentPane.add(jbOK);

		jbCancel = new JButton("取消");
		jbCancel.setSize(60, 30);
		jbCancel.setLocation(300, 210);
		jbCancel.setFont(new Font("宋体", Font.PLAIN, 12));
		jbCancel.setHorizontalTextPosition(JButton.CENTER);
		jbCancel.setOpaque(false);

		contentPane.add(jbCancel);

		return contentPane;
	}

	public static void main(String[] args) {
		new AddNewAccountDialog(new MainFrame());
	}
}
